<template>
  <div class="container" ref="mainCon">
    <topTitle :titleText="titleText"></topTitle>
    <div class="mainCon">
      <el-row class="toolbar searchInputWidth" style="padding-bottom: 0">
        <el-form :inline="true" :model="filterField" ref="accountForm">
          <el-col :lg="8" :xl="6">
            <el-form-item label="企业经营地址" class="row-padding-bottom">
              <el-cascader
                ref="manageArea"
                v-model="bizAreaId"
                :options="areasOptions"
                @change="getAreaId"
                clearable
                filterable
                :props="{ checkStrictly: true }"
                placeholder="请选择"
              ></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :lg="8" :xl="6">
            <el-form-item label="行业" prop="industry">
              <el-cascader
                ref="industry"
                v-model="industryId"
                :options="industryOptionsNC"
                @change="getIndustryId"
                :props="{ checkStrictly: true }"
                clearable
                filterable
              ></el-cascader>
            </el-form-item>
          </el-col>
          <template v-if="advanced">
            <el-col :lg="8" :xl="6">
              <el-form-item label="工资代发" class="row-padding-bottom">
                <el-select
                  v-model="filterField.isSalary"
                  placeholder="请选择"
                  clearable
                >
                  <el-option label="有代发记录" value="1"></el-option>
                  <el-option label="无代发记录" value="0"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :lg="8" :xl="6">
              <el-form-item label="企业累计员工" class="row-padding-bottom">
                <el-select
                  v-model="filterField.isEmployee"
                  placeholder="请选择"
                  clearable
                >
                  <el-option label="有员工" value="1"></el-option>
                  <el-option label="无员工" value="0"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :lg="8" :xl="6">
              <el-form-item label="企业考勤" class="row-padding-bottom">
                <el-select
                  v-model="filterField.isAtt"
                  placeholder="请选择"
                  clearable
                >
                  <el-option label="有考勤" value="1"></el-option>
                  <el-option label="无考勤" value="0"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :lg="8" :xl="6">
              <!-- <el-form-item label="企业员工规模" >
                <el-select v-model="scaleValue" clearable filterable  placeholder="请选择" :disabled="false">
                    <el-option
                        v-for="item in enterpriseScale"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item> -->
            </el-col>
            <el-col :lg="8" :xl="6">
              <el-form-item label="工资专户" class="row-padding-bottom">
                <el-select
                  v-model="filterField.isAccount"
                  placeholder="请选择"
                  clearable
                >
                  <el-option label="已填写" value="1"></el-option>
                  <el-option label="未填写" value="0"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :lg="8" :xl="6">
              <el-form-item label="企业" class="row-padding-bottom">
                <el-input
                  placeholder="输入企业名称或统一社会信用代码"
                  clearable
                  v-model="filterField.name"
                  @blur="filterField.name = changeValue($event)"
                ></el-input>
              </el-form-item>
            </el-col>
          </template>
          <el-col :lg="8" :xl="6">
            <el-form-item label="">
              <a
                @click="toggleAdvanced"
                style="margin-left: 40px; color: #409eff; cursor: pointer"
                class="btnColor"
              >
                {{ advanced ? '收起' : '展开' }}
                <i
                  :class="advanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
                ></i>
              </a>
              <el-button
                type="primary"
                icon="icon iconfont iconchazhao1"
                @click="searchList"
                class="searchBtn"
              >
                <span>搜索</span>
              </el-button>
            </el-form-item>
          </el-col>
          <!-- <el-form-item>
              <el-button type="primary" icon="icon iconfont iconchazhao1" @click="searchTable" class="commonBtn"></el-button>
            </el-form-item> -->
        </el-form>
      </el-row>
      <!-- 列表 -->
      <div class="spacing"></div>
      <div
        ref="tableBox"
        :class="hiddleToolBar ? 'tableBoxCur tableBox' : 'tableBoxCur'"
      >
        <el-table
          ref="tableBox1"
          :max-height="tableHeight"
          :data="tableData"
          :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          v-loading="loading"
          highlight-current-row
          stripe
          style="border: 1px solid #dfe6ec"
        >
          <el-table-column
            align="left"
            prop="companyName"
            label="企业名称"
            width="230"
          >
            <template slot-scope="scope">
              <!-- <el-link type="primary" v-if="isShowDetail" @click="enterpriseArchives(scope.$index, scope.row)">{{scope.row.name}}</el-link>
                <span v-else>{{scope.row.name || "--"}}</span> -->
              <div
                @click="enterpriseArchives(scope.$index, scope.row)"
                class="fontColor"
                v-if="isShowDetail"
              >
                <copyText
                  :tableIndex="scope.$index"
                  :copyTextName="scope.row.name"
                  :columnName="'name'"
                ></copyText>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="uscc"
            label="企业统一社会信用代码"
            min-width="160"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="enterpriseBelongs"
            label="企业归属"
          >
            <template slot-scope="scope">
              <p>{{ scope.row.enterpriseBelongs || '--' }}</p>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="bizAreaName"
            label="企业经营地址"
            min-width="180"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="industryName"
            label="企业所属行业"
            min-width="180"
          ></el-table-column>
          <!-- <el-table-column align="center" prop="scale" label="企业规模"></el-table-column> -->
          <el-table-column
            align="center"
            prop="locatedDate"
            label="企业入驻日期"
            :formatter="formatTd"
            min-width="100"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="empTotal"
            label="企业累计员工"
            min-width="160"
          >
            <template slot-scope="scope">
              <p v-if="scope.row.empTotal">{{ scope.row.empTotal }}</p>
              <p v-if="!scope.row.empTotal">无员工</p>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="attTotal"
            label="企业考勤"
            width="120"
          >
            <template slot-scope="scope">
              <p v-if="scope.row.attTotal">{{ scope.row.attTotal }}</p>
              <p v-if="!scope.row.attTotal">无考勤</p>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="salaryAccountBank,salaryAccount"
            label="工资专户"
            min-width="120"
          >
            <template slot-scope="scope">
              <p>{{ scope.row.salaryAccountBank }}</p>
              <p>
                {{ scope.row.salaryAccount | deseHandler(4, 4, '*') || '--' }}
              </p>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="saAmountTotal"
            label="工资代发"
            min-width="120"
          >
            <template slot-scope="scope">
              <p v-if="scope.row.saAmountTotal">
                {{ scope.row.saAmountTotal }}
              </p>
              <p v-if="!scope.row.saAmountTotal">无代发记录</p>
            </template>
          </el-table-column>
          <!-- 表格数据为空时，页面显示 -->
          <div slot="empty" v-show="isShow">
            <emptyTable emptyText="暂无相关信息"></emptyTable>
          </div>
        </el-table>
        <!-- filterField为搜索条件 -->
        <Pagination
          ref="pagination"
          @getList="getTableList"
          :filterField="filterField"
          :requestUrl="requestUrl"
          @getpageSize="getpageSize"
          @getpageNo="getpageNo"
        ></Pagination>
      </div>
    </div>
  </div>
</template>

<script>
import scrollTable from '@/mixin/scrollTable.js'
import { mapState, mapActions } from 'vuex'
export default {
  name: 'settledEnterprise',
  mixins: [scrollTable],
  data() {
    return {
      requestUrl: 'api-s/nc/companystats/base/monitor/companies', //表格请求路径
      advanced: false,
      date: [], //申请日期
      tableData: [], //表格数据
      filterField: {
        bizAreaId: '',
        industryId: '',
        isEmployee: '', //归属
        isAtt: '', //地址
        isSalary: '', //
        isAccount: '', //审核状态
        name: '', //申请企业名称/代码
      },
      pageSize: 20,
      pageNo: 1,
      // scaleValue: '' ,   //企业规模
      titleText: '企业档案',
      companyId: '',
      isShow: false, //列表加载
      loading: true,
      bizAreaId: '',
      industryId: '',
    }
  },
  computed: { ...mapState(['areasOptions', 'industryOptionsNC']) },
  created() {
    //获取行业
    this.getIndustryNC({})
    //获取区域
    this.getAreas({ areaId: this.$store.state.areaInfoArr.areaId })
    this.$nextTick(function () {
      this.$refs.pagination.getTableListData()
    })
    this.isShowDetail =
      this.$store.state.buttonLimitsArr.indexOf('mNcCompayList:detail') > -1
  },
  activated() {
    this.$nextTick(function () {
      this.$refs.pagination.getTableListData(this.pageNo, this.pageSize)
    })
  },
  methods: {
    toggleAdvanced() {
      this.advanced = !this.advanced
    },
    getpageSize(val) {
      this.pageSize = val
    },
    getpageNo(val) {
      this.pageNo = val
    },
    ...mapActions(['getAreas', 'getIndustryNC']),
    getTableList(data) {
      this.tableData = data
      this.loading = false
      if (this.tableData.length < 1) {
        this.isShow = true
      }
    },
    //列表查询
    searchTable() {
      this.$refs.pagination.getTableListData()
    },
    enterpriseArchives(index, row) {
      this.companyId = row.id
      this.$router.push({
        path: '/home/businessManagement/enterpriseArchives/',
        name: 'enterpriseArchives',
        query: {
          companyId: this.companyId,
          name: 'settledEnterprise',
          // qyName:row.name,
          // qyUscc:row.uscc
        },
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/businessManagement/settledEnterprise',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },

    //获取选中的区域最后一级id
    getAreaId() {
      // if(this.filterField.bizAreaId.length > 0){
      var areaId = this.bizAreaId[this.bizAreaId.length - 1]
      this.filterField.bizAreaId = areaId
      // }
    },
    //获取选中的行业最后一级id
    getIndustryId() {
      // if(this.filterField.industryId.length > 0){
      var industryId = this.industryId[this.industryId.length - 1]
      this.filterField.industryId = industryId
      // }
    },
  },
}
</script>

<style scoped lang="less">
@import '../../../static/css/filterArea.less';
.container {
  .toDownload {
    font-size: 14px;
    color: #0070f5;
    cursor: pointer;
  }
  .mainCon {
    top: 116px;
  }
  .mainCon {
    top: 198px;
  }
}
@media screen and (min-width: 1280px) and (max-width: 1366px) {
  .searchInputWidth /deep/.el-form-item__label {
    width: 96px;
  }
}
.fontColor {
  color: #409eff;
  cursor: pointer;
}
</style>
